package com.lc.activiti.sys.controller;


import com.lc.activiti.config.Result;
import com.lc.activiti.sys.entity.SysDept;
import com.lc.activiti.sys.service.SysDeptService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * 组织架构(SysDept)表控制层
 *
 * @author 骆超
 * @since 2021-07-02 16:21:10
 */
@RestController
@RequestMapping("sysDept")
@Api(tags = "组织架构")
public class SysDeptController {
    /**
     * 服务对象
     */
    @Resource
    private SysDeptService sysDeptService;

    /**
     * 保存或更新部门信息
     * @author 骆超
     * @date 2021/7/2
     * @param sysDept SysDept类实例
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("saveDeptInfo")
    @ApiOperation("保存或更新部门信息")
    public Result saveDeptInfo(@RequestBody SysDept sysDept){
        return sysDeptService.saveDeptInfo(sysDept);
    }

    /**
     * 获取组织架构树
     * @author 骆超
     * @date 2021/7/5
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("getDeptTree")
    @ApiOperation("获取组织架构树")
    public Result getDeptTree(){
        return sysDeptService.getDeptTree();
    }


    /**
     * 获取组织架构树(排除子节点)
     * @author 骆超
     * @date 2021/7/5
     * @param sysDept 参数说明
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("getExceptChildTree")
    @ApiOperation("获取组织架构树(排除子节点)")
    public Result getExceptChildTree(@RequestBody SysDept sysDept){
        return sysDeptService.getExceptChildTree(sysDept);
    }

    /**
     * 删除组织部门信息
     * @author 骆超
     * @date 2021/7/5
     * @param sysDept 参数说明
     * @return com.lc.activiti.config.Result
     */
    @PostMapping("deleteDept")
    @ApiOperation("删除组织部门信息")
    public Result deleteDept(@RequestBody SysDept sysDept){
        return Result.success(sysDeptService.removeById(sysDept));
    }

}
